package com.example.exception_demo.service;

import com.example.exception_demo.entity.User;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserService {
    private static Map<Integer, User> map=new HashMap<>();
    static {
        User user1=new User(1,"John","john@google.com");
        map.put(1,user1);
    }
    //缺少getAll(),update(int id,User user)
    public User getById(int id){
        return map.get(id);
    }
    public User insert(User user){
        map.put(user.getId(),user);
        return user;
    }
    public void delete(int id){
        map.remove(id);
    }

}
